$(function(){
    var menu = $('#gnb > li');
    var wrap = $('#gnbWrap');   
    
    menu.on({
        mouseover:function(){
             var tg = $(this);
            menu.removeClass('on');
            tg.addClass('on');            
             var th = tg.children('a').height() + tg.children('.sGnbArea').height();             
            wrap.stop().animate({height:th});
        },
        mouseout:function(){
            var tg = $(this);
            tg.removeClass('on');
            var th = tg.children('a').height();
            wrap.stop().animate({height:th});
          }
      });
      
      menu.each(function(i){
          var tg = $(this);
          var sub = tg.find('> .sGnbArea > ul > li');
          
          sub.on({
              mouseover:function(event){
                  var tg = $(this);
                  sub.removeClass('on');
                  tg.addClass('on');
              },
              mouseout:function(){
                  var tg = $(this);
                  tg.removeClass('on');
              }
          });
      });
});